<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
	<script type="text/javascript" src="view/jquery/jquery-1.9.1.js"></script>
	<script type="text/javascript" src="view/bootstrap/js/bootstrap.js"></script>
	<link rel="stylesheet" href="view/bootstrap/css/bootstrap.css">
	<link rel="stylesheet" href="view/css/docMan.css">
	<link rel="stylesheet" href="view/toastr/toastr.css">
	<script type="text/javascript" src="view/js/docMan.js"></script>
	<script type="text/javascript" src="view/toastr/toastr.min.js"></script>
	<script type="text/javascript" src="view/js/ajaxfileupload.js"></script>
	<script type="text/javascript" src="view/datapicker/laydate.js"></script>
	<link rel="stylesheet" href="view/css/searchInput.css">
	<link rel="stylesheet" href="view/datapicker/need/laydate.css">
<link rel="stylesheet" href="view/datapicker/skins/molv/laydate.css">
  </head>
  <body style="background: #EDEFF0;">
  	<div id="main-container" class="container" style="height: 100%;width:90%;background: #ffffff">
  		<div class="row" style="height: 100%">
  			<div id="left-p" class="col-sm-2" style="height: 100%;border-right: 1px solid #d2d2d2;"></div>
  			<div  class="col-sm-10" style="height: 100%;">
  				<div class="row mt_10" style="height:100%;width: 100%">
  					<form id="searchForm" action="pageSearch.action" method="post" onkeydown="if(event.keyCode==13){return false;}" >
  						<div class="jq22-search-form">
					        <div id="search-bd" class="search-bd">
					            <ul>
					                <li value="0" <s:if test='pageLucene.searchType=="0"'>class="selected"</s:if> >全文</li>
					                <li value="1" <s:if test='pageLucene.searchType=="1"'>class="selected"</s:if>>标题</li>
					                <li value="2" <s:if test='pageLucene.searchType=="2"'>class="selected"</s:if> class="">文号</li>
					            </ul>
					        </div>
					        <div id="search-hd" class="search-hd">
					            <div class="search-bg"></div>
					            <input type="text" id="s2" class="search-input" name="pageLucene.searchText" value='<s:property value="pageLucene.searchText" />' style="display: inline-block;padding: 17px 5px;">
					            <span class="s1 pholder" style="display: none;">请输入文中任意内容</span>
					            <span class="s2 pholder" style="display: none;">请输入标题</span>
					            <span class="s3 pholder" style="display: none;">请输入文号 </span>
					            <button id="btn_search" class="btn-search" value="搜索"style="font-size:14px;font-family:'Microsoft YaHei';">搜索</button>
					        </div>
					    </div>
						<div class="row" style="margin-top: 10px;">
							<div class="col-md-6" style="width: 45%;">
								从<input id="startDate"  class="form-control laydate-icon" value='<s:date name="pageLucene.startDate" format="yyyy-MM-dd"/>' name="pageLucene.startDate" style="margin-right:10px;margin-left:10px;padding:3px 4px;font-size:13px;width:140px;display:inline;height:30px;" />至
		  						<input id="endDate" class="form-control laydate-icon" value='<s:date name="pageLucene.endDate" format="yyyy-MM-dd"/>' name="pageLucene.endDate" style="margin-right:10px;margin-left:10px;padding:3px 4px;font-size:13px;width:140px;display:inline;height:30px;" />
		  						搜索范围<select class="form-control" name="pageLucene.indexFrom"
								style="width:100px;display:inline;margin:5px;height:30px;font-size:13px;" >
								<option value="-1" <s:if test='pageLucene.indexFrom=="-1"'>selected="selected"</s:if> >不限范围</option>
								<option value="0" <s:if test='pageLucene.indexFrom=="0"'>selected="selected"</s:if>>本系统内</option>
								<option value="1" <s:if test='pageLucene.indexFrom=="1"'>selected="selected"</s:if>>OA系统</option>
								</select>
							
							</div>
							<div class="col-md-6" style="height:50px;padding: 0px;width:30%;">
								<input  type="checkbox" id="islwdwsearch" <s:if test="pageLucene.islwdwSearch==true">checked="checked"</s:if>  style="margin-right:10px;float:left;display: inline;margin-top: 10px;">
								<input  type="hidden" id="inputlwdw"   name="pageLucene.islwdwSearch" value="false"  >
								<h5 style="display: inline;margin-right: 10px;float:left;display: inline;">来文单位:</h5>
								<div style="float:left;display: inline;height:40px;border-left: 5px solid #CEE4F7;padding:5px 12px;"><input  type="radio" id="bj" name="lwdwradio" <s:if test='pageLucene.lwdwb=="1"'>checked="checked"</s:if> style="margin-right:10px;" ><label for="bj">部级</label></div>
								<div style="float:left;display: inline;height:40px;border-left: 5px solid #CEE4F7;padding:5px 12px;"><input  type="radio" id="sj" name="lwdwradio" <s:if test='pageLucene.lwdws=="1"'>checked="checked"</s:if> style="margin-right:10px;"><label for="sj">省级</label></div>
								<div style="float:left;display: inline;height:40px;border-left: 5px solid #CEE4F7;padding:5px 12px;"><input  type="radio" id="shij" name="lwdwradio" <s:if test='pageLucene.lwdwshi=="1"'>checked="checked"</s:if> style="margin-right:10px;"><label for="shij">市级</label></div>
								<div style="float:left;display: inline;height:40px;border-left: 5px solid #CEE4F7;padding:5px 12px;"><input  type="radio" id="qt" name="lwdwradio"  style="margin-right:10px;"><label for="qt">其他</label></div>
								<input  type="hidden" id="lwdwb" name="pageLucene.lwdwb" value="0" style="margin-right:10px;">
								<input  type="hidden" id="lwdws" name="pageLucene.lwdws" value="0" style="margin-right:10px;">
								<input  type="hidden" id="lwdwshi" name="pageLucene.lwdwshi" value="0" style="margin-right:10px;">
							</div>
						</div>
  						<div class="row file_list mt_20">
			  				<s:iterator value="pageLucene.results" id="file" status="stu">
								<div class="indexFile border_bottom" style="min-height: 118px;">
									<div class="text-c"
										style="height:100%;width: 8%;float: left;padding:15px 8px;">
										<div class="<s:property value="#file.imageCssClass" />   ico_cnt ml_10"
											style="float: left;"></div>
									</div>
									<div style="width: 50%;float: left;min-height: 100px;">
										<div class="row ver-middle" style="float: left;padding-top:8px;">
											<div>
												<a class="ellipsis" title="<s:property
														value="#file.fileName" escape="false" />" href="dowloadFile.action?id=<s:property value="#file.fileId" />&indexFrom=<s:property value='#file.indexFrom'/>"
													target="_blank" style="margin-right: 5px;"><span>
													<s:property
														value="#file.fileName" escape="false" />
													</span></a>
											</div>
											<div>
												<span class="muted">
												<s:property value="#file.content" escape="false" />
												</span>
											</div>
											<div class="">
												<span class="muted">[所在位置] 
												<s:if test="#file.indexFrom==1">来源OA系统-收文编号：<s:property value="#file.SWBH" escape="false"  />-来文编号：<s:property value="#file.LWBH" escape="false" />
												-来文单位：<s:property value="#file.LWDW" />
												</s:if>
												<s:else><s:property
														value="#file.filePath" /></s:else>
												</span>
											</div>
										</div>
									</div>
									<div class="ver-middle"
										style="height: 100%;width: 25%;float: left;padding: 12px 8px;margin-left: 20px;">
										<span class="muted">上传人：<s:property
												value="#file.humanName" />
										</span> <br>
										<span class="muted"><s:property 
												value="#file.createTime" /> </span>
													<div class="">
												<a href="dowloadFile.action?id=<s:property value="#file.fileId" />&indexFrom=<s:property value='#file.indexFrom'/> " target="_blank" class=" " style="font-size: 12px;color: #06c;">下载</a>
												<a href="docPreview.action?fileId=<s:property value='#file.fileId'/>&indexFrom=<s:property value='#file.indexFrom'/>"  target="_blank" class="ml_10 " style="font-size: 12px;color: #06c;">预览</a>
												<a href="javascript:void(0)" id="<s:property value="#file.fileId" />" type='<s:property value="#file.indexFrom" />' class="ml_10 file_collect" style="font-size: 12px;color: #06c;">收藏</a>
											</div>
									</div>
								</div>
							</s:iterator>
		  				</div>
		  				
		  				<!--分页按钮  -->
		  				<div class="row" style="margin-top: 20px;margin-bottom: 20px;">
  							<button class="btn btn-link prePage" <s:if test='pageLucene.hasPrePage==false' >disabled="disabled"</s:if> >上一页</button>
  							<input type="number" id="pageIndex" value='<s:property value="pageLucene.currentPage" />' style="width:80px;display: inline;" class="form-control">
  							<input type="number" id="currentPage" name="pageLucene.currentPage" value='<s:property value="pageLucene.currentPage"/>' style="display: none;">
  							<input id="totalPage" value='<s:property value="pageLucene.totalPageCount" />' style="display: none;">
  							<button class="btn btn-link nextPage" type="button" <s:if test='pageLucene.hasNextPage==false' >disabled="disabled"</s:if>>下一页</button>
  							共<span class="pageCount" ><s:property value="pageLucene.totalPageCount"/> </span>页，<s:property value="pageLucene.totalCount"/>条记录
  						</div>
  					</form>
  				</div>
  				
  			</div>
  		</div>
  	</div>
  	<!--文件收藏的modal	  -->
  	<div class="modal fade" id="collectFileModal" tabindex="-1" role="dialog"
		aria-labelledby="exampleModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title" id="exampleModalLabel">文件收藏</h4>
				</div>
				<div class="modal-body">
					<span class="">请选择目标文件夹</span>
					<div class="row myDir_lists linktreeWrap margine_clear mt_10">
						<ul class="disk-copy-ul unstyled">
					  	  <li >
					      	  <a href="javascript:void(0);" class="myFirstDir" id="${personalDirId}">
					      	       <i class="diskpic-copy-right mgtDiskListArrows"></i>
					      	  </a>                                          
					      	  <span class="ch mgtActive"><i class="diskpic-smallbox"></i><span class="me-margin-left5">我的网盘</span></span>
					      </li>
						</ul>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" id="btn_collect" class="btn btn-primary">确定</button>
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
				</div>
			</div>
		</div>
	</div>
	
</body>
  <script type="text/javascript">
 	 laydate.skin('molv');
		laydate({elem:'#startDate'});
		laydate({elem:'#endDate'});
  $(function(){
  	$(".prePage").on("click",function(){
  		var pageCount=Number($("#currentPage").val())-1;
  		$("#currentPage").val(pageCount);
  		console.info($("#currentPage").val());
  		searchType();
  		lwdw();
  		$("#searchForm").submit();
  	});
  	$(".nextPage").on("click",function(){
  		var pageCount=Number($("#currentPage").val())+1;
  		$("#currentPage").val(pageCount);
  		console.info($("#currentPage").val());
  		searchType();
  		lwdw();
  		//window.location="http://localhost:8080/DocMan/pageSearch.action?currentPage="pageCount;
  		$("#searchForm").submit();
  	});
  	$("#pageIndex").on("keyup",function(event){
  		if(event.keyCode=="13"){
  			var currentPage=Math.floor(Number($("#pageIndex").val()));
  			var totalPage=Number($("#totalPage").val());
  			if(currentPage<=0){
  				toast.error("请选择跳转的页数,或正确的页数", "温馨提示");
  			}
  			if(currentPage>totalPage){
  				toast.error("跳转页数不能大于总页数", "温馨提示");
  			}
  			$("#currentPage").val(currentPage);
  			$("#searchForm").submit();
  		}
  	});
  });
  function searchType(){
			var d=$(".selected");
			console.info($(d).val());
			$("#searchType").val($(d).val());
			console.info($("#searchType").val());
		}
  function uploadfile(){
	  var name=$("#upFile").val();
	  var index=name.lastIndexOf("\\");
	  var fileName=name.substring(index+1,name.length);
	  var file=document.getElementById('upFile').files[0];
	  var fileSize="";
	  if (file.size > 1024 * 1024)
          fileSize = (Math.round(file.size * 100 / (1024 * 1024)) / 100).toString() + 'MB';
      else
          fileSize = (Math.round(file.size * 100 / 1024) / 100).toString() + 'KB';
	  console.info(name+fileSize+fileName);
	  $.ajaxFileUpload({
			url:"asynUpload.action",
			secureuri:false,
			fileElementId:'upFile',
			dataType:'json',
			success:function(data,status){
				console.info(data);
				var filePath=data.filePath;
				console.info(filePath);
				var file="<div class=\"row file\">"+
							"<div class=\"col-xs-6\">"+
								"<span class=\"\">"+fileName+"</span>"+
							"</div>"+
							"<div class=\"col-xs-4\">"+
								"<span class=\"muted fileSize \" id=\""+fileSize+"\"> ("+fileSize+") </span>"+
								"<button value=\""+filePath+"\" class=\"btn btn-link padding_clear filePath\">删除</button>"+
							"</div>"+
						 "</div>";
				$("#fileUploadList").append(file);
				//$("#serverFilePath").val(filePath);
			},
			error:function(data,status){
				console.info(data);
			}
		});
	  
  }
  function clickinput(){
	  return $("#upFile").click();
  }
  function lwdw(){
			if($("#islwdwsearch").is(':checked')){
				$("#inputlwdw").val("true");
			}else{
				$("#inputlwdw").val("false");
			}
			if($("#bj").is(':checked'))
			{
				$("#lwdwb").val("1");
				console.info($("#lwdwb").val())
			}
			if($("#sj").is(':checked'))
			{
				$("#lwdws").val("1");
				console.info($("#lwdws").val())
			}
			if($("#shij").is(':checked'))
			{
				$("#lwdwshi").val("1");
				console.info($("#lwdwshi").val())
			}	
		}
		 $(function(){
            //通用头部搜索切换
            $('#search-hd .search-input').on('input propertychange',function(){
                var val = $(this).val();
                if(val.length > 0){
                    $('#search-hd .pholder').hide(0);
                }else{
                    var index = $('#search-bd li.selected').index();
                    $('#search-hd .pholder').eq(index).show().siblings('.pholder').hide(0);
                }
            })
            $('#search-bd li').click(function(){
                var index = $(this).index();
                $('#search-hd .pholder').eq(index).show().siblings('.pholder').hide(0);
                $('#search-hd .search-input').eq(index).show().siblings('.search-input').hide(0);
                $(this).addClass('selected').siblings().removeClass('selected');
                $('#search-hd .search-input').val('');
            });
        })
  </script>
</html>
